<?php

namespace App\Models;

use Encore\Admin\Traits\DefaultDatetimeFormat;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class StockProduct extends Model
{
    use SoftDeletes;
    use DefaultDatetimeFormat;

    protected $table = 'stock_product';

    public function depot(){
        return $this->belongsToMany(StockDepot::class, 'stock_depot_product', 'product_id', 'depot_id')
            ->withPivot('num');
    }

    public function reports(){
        return $this->belongsToMany(StockReport::class, 'stock_report_product', 'product_id', 'report_id')
            ->withPivot(['product_count','product_desc']);
    }

}
